package com.wongoing.base;

public class Json<T> implements java.io.Serializable {
	private static final long serialVersionUID = -7243126936772533871L;
	private String title = "失败提示";
	private String message = "接口访问失败";
	private boolean status = false;
	private int statusCode = 300;
	private T data;
	
	public Json() {
		super();
	}

	public Json(String message) {
		super();
		this.message = message;
	}

	public Json(String message, int statusCode, T data) {
		super();
		this.message = message;
		this.statusCode = statusCode;
		this.data = data;
	}

	public Json(String title, String message, boolean status, int statusCode) {
		super();
		this.title = title;
		this.message = message;
		this.status = status;
		this.statusCode = statusCode;
	}

	public Json(String title, String message, boolean status, int statusCode, T data) {
		super();
		this.title = title;
		this.message = message;
		this.status = status;
		this.statusCode = statusCode;
		this.data = data;
	}
	
	public Json<T> success(T data) {
		this.title = "成功提示";
		this.message = "接口访问成功";
		this.status = true;
		this.statusCode = 200;
		this.data = data;
		return this;
	}
	
	public Json<T> success() {
		this.title = "成功提示";
		this.message = "接口访问成功";
		this.status = true;
		this.statusCode = 200;
		this.data = null;
		return this;
	}
	
	public Json<T> fail(T data) {
		this.data = data;
		return this;
	}
	
	public Json<T> fail() {
		this.data = null;
		return this;
	}
	
	public Json<T> fail(T data, String message) {
		this.data = data;
		this.message = message;
		return this;
	}
	
	public int getStatusCode() {
		return statusCode;
	}

	public void setStatusCode(int statusCode) {
		this.statusCode = statusCode;
	}

	public String getMessage() {
		return message;
	}
	
	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}
	
	public T getData() {
		return this.data;
	}
	
	public void setData(T data) {
		this.data = data;
	}
	
	
}
